﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>修改密码</title>
    @Html.Style("~/scripts/layuiadmin/layui/css/layui.css")
    @Html.Style("~/scripts/layuiadmin/style/admin.css")
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header">修改密码</div>
            <div class="layui-card-body" style="padding: 15px;">
                <div class="layui-form" lay-filter="form-filter">
                    <div class="layui-form-item">
                        <label class="layui-form-label">密码</label>
                        <div class="layui-input-block">
                            <input type="password" name="password" class="layui-input" placeholder="请输入密码" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">确认密码</label>
                        <div class="layui-input-block">
                            <input type="password" name="okPassword" class="layui-input" placeholder="请输入确认密码" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-block" id="btnOk">确定修改</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @Html.Script("~/scripts/layuiadmin/layui/layui.js")
    <script type="text/javascript">
        var dataTableObj = undefined;
        layui.use(['form', 'layer', 'table', 'upload', 'element'], function () {
            var layer = layui.layer,
                form = layui.form,
                element = layui.element,
                $ = layui.$;

            $('#btnOk').click(function () {
                var passwords = form.val('form-filter');

                if (passwords.password.length < 6 || passwords.password.length > 12) {
                    layer.msg('密码6-12位');
                    return;
                }

                if (passwords.password != passwords.okPassword) {
                    layer.msg('两次输入密码不一致');
                    return;
                }

                $.post('/admin/modify-password', {
                    password: passwords.password
                }, function (data) {
                    if (data.code == 1) {
                        layer.msg('修改成功');
                    } else {
                        layer.msg(data.msg);
                    }
                });
            });
        });
    </script>
</body>
</html>
